<template>
	<view class="container">
		<uni-forms :modelValue="formData">
			<uni-forms-item label="金额" name="name" class="flex">
				<view class="flex">
					<uni-number-box :min="1" v-model="formData.amount"></uni-number-box>
					<view>元</view>
				</view>
			</uni-forms-item>
		</uni-forms>
		<button @click="payStart">充值</button>
	</view>
</template>

<script>
	import {
		post
	} from '@/util/request.js'
	export default {
		data() {
			return {
				formData:{
					amount:1
				}
			}
		},
		mounted(){
			if(location.hostname == 'h5pay.yezi-yezi.com'){
				uni.switchTab({
					url: '/pages/index_yzsc/index'
				})
			}else{
				uni.setNavigationBarTitle({
					title: '椰子企业'
				})
			}
		},
		methods: {
			payStart(){
				post('baseURL', '/rechargeFlow/payH5', {
					amount: this.formData.amount
				}).then(res => {
					console.log(res, 'ok')
					if(res.success){
						location.href = res.data
					}
				}).catch(err => {
					console.log(err, 'err')
				})
			}
		}
	}
</script>

<style scoped>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
	.flex{
		display: flex;
		align-items: center;
	}
	
</style>
